import {
  wxRequest
} from '@/utils/wxRequest'
import constant from '@/utils/constant'
// const apiMall = 'http://192.168.0.105:10005/'
// const apiMall = 'https://wx.liziyd.com/'
const apiMall = 'http://192.168.0.178:10005/'
// const apiMall = 'http://localhost:8080/'
/**
 * 下面的所有接口都是资源-在线题库相关的
 */
/** -----------------------------------------一条快乐的分割线-----------------------------------------------------**/

/**
 * 获取首页相关信息
 * resourceType:1视频 2图书 3题库 4线下活动
 */
const getResourceIndex = (params) => wxRequest(params, apiMall + 'interface/app/leaderPageApp/leaderPageInfo.json?resourceType=' + constant.RESOURCE)
/**
 * 保存用户答题信息【APP】
 */
const addOnlineAnswerApp = (params) => wxRequest(params, apiMall + 'interface/app/examonlineone/addOnlineAnswerApp.json')
/**
 * 在线题库下载量/答题量增加
 */
const addDownloadCount = (params) => wxRequest(params, apiMall + 'examonlineone/addDownloadCount.json')
/**
 * 在线题库列表分页查询【APP】
 */
const examonlineonePageApp = (params) => wxRequest(params, apiMall + 'interface/app/examonlineone/pageApp.json')
/**
 * 在线题库列表查询【APP】
 */
const examonlineoneListApp = (params) => wxRequest(params, apiMall + 'examonlineone/listApp.json')
/**
 * 在线题库查询详情
 */
const examonlineoneInfo = (params) => wxRequest(params, apiMall + 'interface/app/examonlineone/info.json')
/**
 * 在线题库根据ID删除
 */
const examonlineoneDeleteById = (params) => wxRequest(params, apiMall + 'examonlineone/deleteById.json')
/**
 * 在线题库精品推荐【APP】
 */
const boutiqueListApp = (params) => wxRequest(params, apiMall + 'examonlineone/boutiqueListApp.json')
/**
 * 点击查看解析
 */
const onlineAnalysis = (params) => wxRequest(params, apiMall + 'interface/app/examonlineone/onlineAnalysis.json')
/**
 * 点击答题
 */
const onlineAnswer = (params) => wxRequest(params, apiMall + 'interface/app/examonlineone/onlineAnswer.json')
/**
 * 相关资源推荐查询
 */
const recommendListByOnlineId = (params) => wxRequest(params, apiMall + 'examonlineonerecommend/recommendListByOnlineId')
/**
 * 分页查询资源列表
 */
const getResourceList = (params) => wxRequest(params, apiMall + 'interface/app/course/getPage.json')
/**
 * 获取标签页
 */
const getResourceTab = (params) => wxRequest(params, apiMall + 'interface/app/stdtag/getList.json?tagLevel=1')

/** ---------------------------------------------------------------------------------------------------一条快乐的分割线------------------------------------------------------------------------------------------------**/
/** ---------------------------------------------------------------------------------------------------两条快乐的分割线------------------------------------------------------------------------------------------------**/
/** ---------------------------------------------------------------------------------------------------三条快乐的分割线------------------------------------------------------------------------------------------------**/
/** ---------------------------------------------------------------------------------------------------四条快乐的分割线------------------------------------------------------------------------------------------------**/
/**
 * 下面的所有接口都是课程相关的
 */
/** ---------------------------------------------------------------------------------------------------一条快乐的分割线------------------------------------------------------------------------------------------------**/
/** ---------------------------------------------------------------------------------------------------两条快乐的分割线------------------------------------------------------------------------------------------------**/
/** ---------------------------------------------------------------------------------------------------三条快乐的分割线------------------------------------------------------------------------------------------------**/
/** ---------------------------------------------------------------------------------------------------四条快乐的分割线------------------------------------------------------------------------------------------------**/

/**
 * 获取首页相关数据
 */
const getCurriculumIndex = (params) => wxRequest(params, apiMall + 'interface/app/leaderPageApp/leaderPageInfo.json?resourceType=' + constant.CURRICULUM)
/**
 * 获取所有精品推荐
 */
const getCurriculumRecommend = (params) => wxRequest(params, apiMall + '/interface/app/course/getPage.json')
/**
 * 获取标签页
 */
const getCurriculumTab = (params) => wxRequest(params, apiMall + 'interface/app/stdtag/getList.json?tagLevel=1')
/**
 * 获取排序方式
 */
const getCurriculumSortList = (params) => wxRequest(params, apiMall + '')
/**
 * 相关推荐
 * @param  {[String]} cCoursesId [课程id]
 * @return {[JSON]}        [description]
 * 返回resourceType 1,:"资源"2,":"在线课程":3,:"在线图书"4,:"在线题库"
 */
const getCurriculumRecommendList = (params) => wxRequest(params, apiMall + '/interface/app/cCoursesRecommend/recommendListByCoursesId.json')

/**
 * 相关推荐大集合
 */
const getRecommendAllList = (params) => wxRequest(params, apiMall + '/interface/app/cCoursesRecommend/recommendAllList.json')

/**
 * 课时不分页
 * @param  {[String]} coursesId [课程id]
 * @param  {[String]} lessonName [课程名称的模糊查询]
 */
const getCurriculumLessonsList = (params) => wxRequest(params, apiMall + '/interface/app/lessons/list.json')
/**
 * 课时分页接口
 * @param  {[String]} pageNum [页码]
 * @param  {[String]} pageSize [每页条数]
 * @param  {[String]} coursesId [课程id]
 * @param  {[String]} lessonName [课程名称的模糊查询]
 * @return {[JSON]}        [description]
 */
const getCurriculumLessonsPage = (params) => wxRequest(params, apiMall + '/interface/app/lessons/getPage.json')
/**
 * 课时播放
 * @param  {[String]} coursesId [课时id]
 * @param {[String]} userId [用户id](可选)
 */
const getCurriculumLessonsPlay = (params) => wxRequest(params, apiMall + '/interface/app/lessons/play.json')
/**
 * 课时点击量增加
 * @param {[String]} id [课时id]
 */
const addCurriculumClickCount = (params) => wxRequest(params, apiMall + '/interface/app/lessons/addClickCount.json')
/**
 * 课时详情
 * @param {[String]} pageNum [页码]
 */
const getCurriculumLessonsInfo = (params) => wxRequest(params, apiMall + '/interface/app/lessons/info.json')
/**
 * 课程分页查询
 * @param {[String]} pageNum [页码]
 * @param  {[String]} pageSize [每页条数]
 * @param  {[String]} courseName [模糊查询的课程名称]
 * @param {[String]} tagId [标签ID]
 * @param {[String]} orderType [排序类型-1:时间倒序 2:销量倒序 3:最热倒序
 *                                      4:人气倒序 5:价格倒序 6:时间正序
 *                                      7:销量正序 8:最热正序 9:人气正序
 *                                      10:价格正序]
 */
const getCurriculumPage = (params) => wxRequest(params, apiMall + '/interface/app/course/getPage.json')
/**
 * 课程评论接口
 * @param {[String]} pageNum [页码]
 * @param  {[String]} pageSize [每页条数]
 * @param  {[String]} courseId [课程ID]
 */
const getCurriculumCommentPage = (params) => wxRequest(params, apiMall + '/interface/app/ccomment/getPage.json')

/**
 * 课程评论新增 [POST]
 * @param {[String]} courseId [课程ID]
 * @param  {[String]} comContent [评论内容]
 * @param  {[String]} comPerson [评论人ID]
 */
const addCurriculumComment = (params) => wxRequest(params, apiMall + '/interface/app/ccomment/add.json')

/**
 * 课程详情
 * @param {[String]} id [课程ID]
 * @param  {[String]} userId [用户ID 查询是否购买、收藏用
 */
const getCurriculumInfo = (params) => wxRequest(params, apiMall + '/interface/app/course/info.json')

/**
 * 课程问答列表分页
 * @param {[String]} pageNum [页码]
 * @param  {[String]} pageSize [每页条数]
 * @param  {[String]} courseId [课程ID]
 */
const getCurriculumQaPage = (params) => wxRequest(params, apiMall + '/interface/web/coursesQa/getPage.json')

/**
 * 课程问答新增 [POST]
 * @param  {[String]} courseId [课程ID]
 * @param {[String]} qaProblem [问题内容]
 * @param {[String]} problemUser [提问人ID]
 */
const addCurriculumQa = (params) => wxRequest(params, apiMall + '/interface/web/coursesQa/add.json')

/** -----------------------------------------下面是收藏相关的接口-------------------------------------------------**/
/** 添加/取消收藏 */
const collect = (params) => wxRequest(params, apiMall + 'interface/app/userResourceCollect/existsApp.json')
/** 分页查询我的收藏 */
const collectPage = (params) => wxRequest(params, apiMall + 'interface/app/userResourceCollect/pageMyCollect.json')
/** 不分页查询我的收藏 */
const collectList = (params) => wxRequest(params, apiMall + 'interface/app/userResourceCollect/myCollect.json')
/** 收藏数量 */
const collectCount = (params) => wxRequest(params, apiMall + 'interface/app/userResourceCollect/collectCount.json')
/** 查询是否已经收藏 */
const isCollect = (params) => wxRequest(params, apiMall + 'interface/app/userResourceCollect/isExists.json')

/** -----------------------------------------上面是收藏相关的接口-------------------------------------------------**/

/** -------------------------------------------下面的接口是登录相关的接口------------------------------------------**/
/** 小程序code登录接口 */
const loginByCode = (params) => wxRequest(params, apiMall + 'oauth/login.json')
/** 小程序解密接口 */
const decode = (params) => wxRequest(params, apiMall + 'oauth/decryption.json')
/** 小程序sessionId登录接口 */
const loginBySessionId = (params) => wxRequest(params, apiMall + 'oauth/slogin.json')
/** 小程序账号绑定接口 */
const binding = (params) => wxRequest(params, apiMall + 'oauth/bind.json')
/** 用户注册接口 */
const register = (params) => wxRequest(params, apiMall + 'usercenter/registerAndBind.json')
/** 获取短信校验码接口 */
const getMessageCode = (params) => wxRequest(params, apiMall + 'phoneCode2.json')
/** 获取验证码 */
const getAuthCode = (params) => wxRequest(params, apiMall + 'getImgCode.json')
/** 验证验证码 */
const checkAuthCode = (params) => wxRequest(params, apiMall + 'checkVrifyCode')
/** --------------------------------------------上面是登录相关的接口----------------------------------------- **/

/** ---------------------------------------------下面是个人中心相关的接口-------------------------------------**/
/** -------------------------------------------------------------------地址管理相关接口--------------------- **/
/** 获取用户全部的地址信息 */
const getUserAddressList = (params) => wxRequest(params, apiMall + 'interface/app/userAddress/page.json')
/** 根据Id删除地址 */
const removeAddressById = (params) => wxRequest(params, apiMall + 'interface/app/userAddress/deleteById.json')
/** 根据Id查找地址 */
const getAddressById = (params) => wxRequest(params, apiMall + 'interface/app/userAddress/info.json')
/** 编辑地址 */
const editAddress = (params) => wxRequest(params, apiMall + 'interface/app/userAddress/updateUserAddress.json')
/** 新增收货地址 */
const addAddress = (params) => wxRequest(params, apiMall + 'interface/app/userAddress/addUserAddress.json')
/** 新增编辑页面获取全部省市区信息 */
const getRegion = (params) => wxRequest(params, apiMall + 'interface/app/userAddress/getRegion.json')
/** --------------------------------------------------------------------消息相关接口-------------------------**/

/** 分页获取我的消息 */
const getMyMessageList = (params) => wxRequest(params, apiMall + 'interface/app/send-message/pageMyMessage.json')
/** 设置消息为已读状态 */
const readMessage = (params) => wxRequest(params, apiMall + 'interface/app/send-message/signRead.json')
/** 消息详情 */
const getMessageDetail = (params) => wxRequest(params, apiMall + 'interface/app/send-message/info.json')

/** ----------------------------------------------------------------------帮助与反馈相关接口----------------- **/
/** 获取所有帮助类别 */
const getHelpTypeList = (params) => wxRequest(params, apiMall + 'interface/app/help-feedback-type/list.json')
/** 根据帮助类别ID获取对应的帮助详情列表 */
const getHelpDetailList = (params) => wxRequest(params, apiMall + 'interface/app/help-feedback-manage/listToApp.json')
/** 根据帮助id获取对应的帮助详情信息 */
const getHelpDetail = (params) => wxRequest(params, apiMall + 'interface/app/help-feedback-manage/info.json')

/** ----------------------------------------------------------------------签到相关接口------------------------**/
/** 判断用户当天是否签到和连续签到天数 */
const isSigninNow = (params) => wxRequest(params, apiMall + 'interface/app/signin/isSigninNow.json')
/** 最近7天的签到记录 */
const getWeeklist = (params) => wxRequest(params, apiMall + 'interface/app/signin/getWeekList.json')
/** 签到接口 */
const userSignin = (params) => wxRequest(params, apiMall + 'interface/app/signin/userSignin.json')
/** ----------------------------------------------------------------------我的订单相关接口------------------- */
/** 分页获取我的订单 */
const getMyOrder = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/pageMyOrder.json')
/** 根据id获取订单详情 */
const getOrderDetail = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/getById.json')
/** 取消订单 */
const cancelOrder = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/cancelToOrder.json')
/** 删除订单 */
const deleteOrder = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/deleteByIds.json')
/** ------------------------------------------------------------------------购买相关接口---------------------- */
/** 第一步:点击购买 */
const clickToBuy = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/clickToBuy.json')
/** 第二步: 根据订单id,得到订单信息 */
const getOrderById = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/getById.json')
/** 第三步: 提交订单 */
const buyToOrder = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/buyToOrder.json')
/** 第四步: 检查订单是否已经支付 */
const getMongoOrderById = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/getMongoOrderById.json')
/** 第五步: 提交订单后根据订单ID得到订单信息 */
const isPay = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/isPay.json')
/** 检测订单是否存储已下架商品 */
const checkOrderById = (params) => wxRequest(params, apiMall + 'interface/app/bizOrders/checkOrderById.json')
/** 支付接口 */
// const dopay = (params) => wxRequest(params, apiMall + 'pay/interface/mobilepay/weixin/dopay.json')
/** 微信小程序支付 */
const dopay = (params) => wxRequest(params, apiMall + 'pay/interface/miniAppPay/weixin/dopay.json')
/** ---------------------------------------------------------------------我的课程------------------------------ */
const getCurriculumListByUser = (params) => wxRequest(params, apiMall + 'interface/app/course/getListByUser.json')

/** ---------------------------------------------------------------------我的题库------------------------------ */
const getResourceListByUser = (params) => wxRequest(params, apiMall + 'interface/app/examonlineone/getListByUser.json')

/** ---------------------------------------------------------------------积分相关接口------------------------ **/
/** 根据用户id获取对应的积分 */
const getUserPoints = (params) => wxRequest(params, apiMall + 'interface/app/userPoints/getAllDetail.json')
/** 根据用户id获取对应的积分和优惠券数量 */
const getPointsAndCoupon = (params) => wxRequest(params, apiMall + 'interface/app/userPoints/getPointsAndCoupon.json')
/** ---------------------------------------------------------------------优惠券相关接口------------------------ **/

/** 根据资源和用户id获取对应的优惠券 */
const getResCoupon = (params) => wxRequest(params, apiMall + 'interface/app/couponUser/getResCoupon.json')
/** -------------------------------------------------------------------编辑用户信息接口---------------------- **/
const saveUserInfo = (params) => wxRequest(params, apiMall + 'interface/app/user/update.json')
/** ---------------------------------------------------------------------图片上传接口------------------------- **/
const imgUpload = (params) => wxRequest(params, apiMall + 'upload/imgUpload')
export default {
  getResourceIndex,
  getResourceList,
  getResourceTab,
  getCurriculumIndex,
  getCurriculumRecommend,
  getCurriculumTab,
  getCurriculumSortList,
  getCurriculumRecommendList,
  getCurriculumLessonsList,
  getCurriculumLessonsPage,
  getCurriculumLessonsPlay,
  addCurriculumClickCount,
  getCurriculumLessonsInfo,
  getCurriculumPage,
  getCurriculumCommentPage,
  addCurriculumComment,
  getCurriculumInfo,
  getCurriculumQaPage,
  addCurriculumQa,
  collect,
  collectPage,
  collectList,
  collectCount,
  isCollect,
  addOnlineAnswerApp,
  addDownloadCount,
  examonlineonePageApp,
  examonlineoneListApp,
  examonlineoneInfo,
  examonlineoneDeleteById,
  boutiqueListApp,
  onlineAnalysis,
  onlineAnswer,
  recommendListByOnlineId,
  loginByCode,
  loginBySessionId,
  binding,
  register,
  getMessageCode,
  getUserAddressList,
  removeAddressById,
  getAddressById,
  editAddress,
  addAddress,
  getRegion,
  getAuthCode,
  checkAuthCode,
  getMyMessageList,
  readMessage,
  getMessageDetail,
  isSigninNow,
  getWeeklist,
  userSignin,
  getUserPoints,
  saveUserInfo,
  imgUpload,
  getHelpTypeList,
  getHelpDetailList,
  getHelpDetail,
  deleteOrder,
  getMyOrder,
  getOrderDetail,
  cancelOrder,
  getCurriculumListByUser,
  getRecommendAllList,
  getPointsAndCoupon,
  getResCoupon,
  buyToOrder,
  getMongoOrderById,
  getOrderById,
  isPay,
  clickToBuy,
  checkOrderById,
  dopay,
  getResourceListByUser,
  decode
}
